package com.athui.bean.metadata;

import org.apache.flink.api.common.typeinfo.TypeInformation;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * @description: TODO
 * @autor: zhangzhonghui
 * @create: 2024-08-01 12:18
 * @Version: 1.0
 */
public class ColumnMetaData extends ColumnMetaDataDim implements Comparable<ColumnMetaData>, Cloneable, Serializable {

    /**
     * @description: TODO 任务编码
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:18
     * @Version: 1.0
    **/
    private Long taskCode;

    /**
     * @description: TODO 表编码
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:18
     * @Version: 1.0
    **/
    private String tableCode;

    /**
     * @description: TODO ID
     * @author: 阿辉大人
     * @create: 2024/8/3 18:30
     * @version: 1.0
    **/
    private String columnCode;

    /**
     * @description: TODO 列索引,用于定位 源数据与列的关系。
     * @author: 阿辉大人
     * @create: 2024/8/3 18:30
     * @version: 1.0
    **/
    private String index;

    /**
     * @description: TODO  列名
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:18
     * @Version: 1.0
    **/
    @NotBlank(message = "columnName is required")
    private String columnName;

    /**
     * @description: TODO 列类型
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:23
     * @Version: 1.0
    **/
    @NotBlank(message = "database column type is required")
    private String originalColumnType;

    /**
     * @description: TODO flink 数据类型
     * @autor: zhangzhonghui
     * @create: 2024/8/1 15:51
     * @Version: 1.0
    **/
    @NotNull(message = "flink column type is required")
    private TypeInformation flinkColumnType;

    /**
     * @description: TODO 列类型标签
     * @autor: zhangzhonghui
     * @create: 2024/8/1 15:51
     * @Version: 1.0
    **/
    @NotNull(message = "typeLabel type is required")
    private Integer typeLabel;

    /**
     * @description: TODO 列的精度
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:40
     * @Version: 1.0
    **/
    private Integer columnPrecision = 0;

    /**
     * @description: TODO 列的标度
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:40
     * @Version: 1.0
     **/
    private Integer columnScale = 0;

    /**
     * @description: TODO 列的注释
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:40
     * @Version: 1.0
     **/
    private String columnComment;

    /**
     * @description: TODO 是否允许为Null
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:23
     * @Version: 1.0
     **/
    private Boolean isAllowNull = true;

    /**
     * @description: TODO 是否为主键
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:23
     * @Version: 1.0
     **/
    private Boolean isKey = false;

    /**
     * @description: TODO 主键类型
     * @autor: zhangzhonghui
     * @create: 2024/8/1 12:23
     * @Version: 1.0
     **/
    private String keyType;

    /**
     * @description: TODO 是否为无效列
     *  当invalidColumn数值true时，该列数据是不会做计算的。
     * @author: 阿辉大人
     * @create: 2024/8/23 06:59
     * @version: 1.0
    **/
    private Boolean invalidColumn = false;



    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    public Long getTaskCode() {
        return taskCode;
    }

    public void setTaskCode(Long taskCode) {
        this.taskCode = taskCode;
    }

    public String getTableCode() {
        return tableCode;
    }

    public void setTableCode(String tableCode) {
        this.tableCode = tableCode;
    }

    public String getColumnCode() {
        return columnCode;
    }

    public void setColumnCode(String columnCode) {
        this.columnCode = columnCode;
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getOriginalColumnType() {
        return originalColumnType;
    }

    public void setOriginalColumnType(String originalColumnType) {
        this.originalColumnType = originalColumnType;
    }

    public TypeInformation getFlinkColumnType() {
        return flinkColumnType;
    }

    public void setFlinkColumnType(TypeInformation flinkColumnType) {
        this.flinkColumnType = flinkColumnType;
    }

    public Integer getTypeLabel() {
        return typeLabel;
    }

    public void setTypeLabel(Integer typeLabel) {
        this.typeLabel = typeLabel;
    }

    public Integer getColumnPrecision() {
        return columnPrecision;
    }

    public void setColumnPrecision(Integer columnPrecision) {
        this.columnPrecision = columnPrecision;
    }

    public Integer getColumnScale() {
        return columnScale;
    }

    public void setColumnScale(Integer columnScale) {
        this.columnScale = columnScale;
    }

    public String getColumnComment() {
        return columnComment;
    }

    public void setColumnComment(String columnComment) {
        this.columnComment = columnComment;
    }

    public Boolean getAllowNull() {
        return isAllowNull;
    }

    public void setAllowNull(Boolean allowNull) {
        isAllowNull = allowNull;
    }

    public Boolean getKey() {
        return isKey;
    }

    public void setKey(Boolean key) {
        isKey = key;
    }

    public String getKeyType() {
        return keyType;
    }

    public void setKeyType(String keyType) {
        this.keyType = keyType;
    }

    public Boolean getInvalidColumn() {
        return invalidColumn;
    }

    public void setInvalidColumn(Boolean invalidColumn) {
        this.invalidColumn = invalidColumn;
    }

    @Override
    public String toString() {
        return "ColumnMetaData{" +
                "columnCode='" + columnCode + '\'' +
                ", index=" + index +
                ", columnName='" + columnName + '\'' +
                ", originalColumnType='" + originalColumnType + '\'' +
                ", flinkColumnType=" + flinkColumnType +
                ", typeLabel=" + typeLabel +
                ", columnPrecision=" + columnPrecision +
                ", columnScale=" + columnScale +
                ", columnComment='" + columnComment + '\'' +
                ", isAllowNull=" + isAllowNull +
                ", isKey=" + isKey +
                ", keyType='" + keyType + '\'' +
                "totalCount=" + super.getTotalCount() +
                ", emptyValueCount=" + super.getEmptyValueCount() +
                ", nullValueCount=" + super.getNullValueCount() +
                ", zeroValueCount=" + super.getZeroValueCount() +
                ", repeatValueCount=" + super.getRepeatValueCount() +
                ", notRepeatValueCount=" + super.getNotRepeatValueCount() +
                ", nonStandardValueCount=" + super.getNonStandardValueCount() +
                ", illegalityValueCount=" + super.getIllegalityValueCount() +
                ", textMinLength=" + super.getTextMinLength() +
                ", textMaxLength=" + super.getTextMaxLength() +
                ", numericalMinValue=" + super.getNumericalMinValue() +
                ", numericalMaxValue=" + super.getNumericalMaxValue() +
                ", invalidValueCount=" + super.getInvalidValueCount() +
                ", involvedValueCount=" + super.getInvolvedValueCount() +
                '}';
    }

    @Override
    public int compareTo(ColumnMetaData columnMetaData) {
        return this.getTotalCount().compareTo(columnMetaData.getTotalCount());
    }
}
